Skip to content

Digital Credentials: Add WebDriver automation commands and tests#58587

Open
mohamedamir wants to merge 4 commits into
web-platform-tests:masterfrom
mohamedamir:digital-credentials-webdriver-tests
Open

Digital Credentials: Add WebDriver automation commands and tests#58587
mohamedamir wants to merge 4 commits into
web-platform-tests:masterfrom
mohamedamir:digital-credentials-webdriver-tests

Conversation

@mohamedamir
Copy link
Copy Markdown
Contributor

@mohamedamir mohamedamir commented Mar 18, 2026

This PR adds WebDriver BiDi automation support for the Digital Credentials API in Web Platform Tests (WPT), implementing the spec changes proposed in w3c-fedid/digital-credentials#381.

Summary of Changes

Infrastructure Support

  • WebDriver BiDi Integration: Implements support for the digitalCredentials.setVirtualWalletBehavior command as defined in the Digital Credentials specification.
  • wptrunner Updates: Adds necessary protocol parts and actions in protocol.py, actions.py, and executorwebdriver.py to handle the BiDi command via the browser's BiDi session.
  • testdriver.js Extensions: Exposes test_driver.set_virtual_wallet_behavior to tests, allowing them to configure the simulated wallet's response to API calls.

Tests

  • WebDriver Tests: Introduces automated tests for navigator.credentials.get() and navigator.credentials.create() in the digital-credentials/webdriver/ directory.
  • Test Coverage:
    • Respond: Verifies that the API resolves successfully with the data provided by the mock wallet (supporting both simple strings and complex structured objects).
    • Decline: Verifies that the API rejects with NotAllowedError when the mock wallet simulates a user decline.
    • Wait: Verifies that the API remains pending when the mock wallet is set to wait, and correctly handles abort signals.
  • State Isolation: Tests include cleanup steps to reset the virtual wallet behavior, ensuring no side effects on subsequent tests.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds WebDriver automation hooks for the Digital Credentials API so WPT tests can drive navigator.credentials.get() / create() using a simulated “virtual wallet” response mode.

Changes:

  • Added new test_driver/wptrunner actions to set virtual wallet behavior (respond / wait / decline).
  • Added a WebDriver protocol part wiring these actions to session extension commands under digital-credentials/*.
  • Introduced new end-to-end WebDriver tests for navigator.credentials.get() and navigator.credentials.create().

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tools/wptrunner/wptrunner/testdriver-extra.js Exposes new test_driver_internal.* hooks that enqueue wptrunner actions for virtual wallet control.
tools/wptrunner/wptrunner/executors/protocol.py Defines DigitalCredentialsProtocolPart interface for wallet automation.
tools/wptrunner/wptrunner/executors/executorwebdriver.py Implements the WebDriver-backed protocol part and registers it in the WebDriver protocol.
tools/wptrunner/wptrunner/executors/actions.py Adds action handlers mapping testdriver messages to protocol.digital_credentials.* calls.
resources/testdriver.js Exposes new test_driver.* API surface and vendor-stub methods for the new commands.
digital-credentials/webdriver/get.https.html New WebDriver E2E tests for navigator.credentials.get() covering respond/decline/wait+abort flows.
digital-credentials/webdriver/create.https.html New WebDriver E2E tests for navigator.credentials.create() covering respond/decline/wait+abort flows.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread digital-credentials/webdriver/create.https.html Outdated
Comment thread tools/wptrunner/wptrunner/executors/executorwebdriver.py Outdated
Comment thread digital-credentials/webdriver/get.https.html
Comment thread digital-credentials/webdriver/get.https.html Outdated
Comment thread digital-credentials/webdriver/create.https.html
@mohamedamir mohamedamir force-pushed the digital-credentials-webdriver-tests branch from 52ff1d1 to 6dba083 Compare March 26, 2026 21:33
@mohamedamir mohamedamir marked this pull request as ready for review March 26, 2026 21:34
@mohamedamir mohamedamir requested a review from a team as a code owner March 26, 2026 21:34
@wpt-pr-bot wpt-pr-bot added digital-credentials infra testdriver.js wg-s_fedid wptrunner The automated test runner, commonly called through ./wpt run labels Mar 26, 2026
@mohamedamir mohamedamir force-pushed the digital-credentials-webdriver-tests branch 3 times, most recently from 24484fe to dc075e0 Compare April 24, 2026 20:56
@mohamedamir mohamedamir force-pushed the digital-credentials-webdriver-tests branch from dc075e0 to 0d6819b Compare April 24, 2026 21:02
marcoscaceres added a commit to marcoscaceres/WebKit that referenced this pull request May 8, 2026
…r automated testing

https://bugs.webkit.org/show_bug.cgi?id=306292

Reviewed by NOBODY (OOPS!).

Add a WebDriver BiDi `digitalCredentials` module that enables automated
testing of digital credential flows without requiring a real wallet.

The module provides a `setVirtualWalletBehavior` command that configures
how the user agent responds to credential requests during automation:
- "respond": returns a synthetic credential with the given protocol and response data
- "decline": rejects the request with a NotAllowedError
- "wait": leaves the credential promise unsettled
- "clear": removes the configured behavior

Behavior can be scoped to a specific browsing context or set as the
session default. The interception occurs in WebPageProxy before the
platform credential picker is shown.

Spec: https://w3c-fedid.github.io/digital-credentials/#automated-testing
WPT: web-platform-tests/wpt#58587

* Source/WebKit/CMakeLists.txt:
* Source/WebKit/Sources.txt:
* Source/WebKit/UIProcess/Automation/BidiDigitalCredentialsAgent.cpp: Added.
* Source/WebKit/UIProcess/Automation/BidiDigitalCredentialsAgent.h: Added.
* Source/WebKit/UIProcess/Automation/WebDriverBidiProcessor.cpp:
* Source/WebKit/UIProcess/Automation/WebDriverBidiProcessor.h:
* Source/WebKit/UIProcess/Automation/protocol/BidiDigitalCredentials.json: Added.
* Source/WebKit/UIProcess/WebPageProxy.cpp:
Copy link
Copy Markdown
Contributor

@marcoscaceres marcoscaceres left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI infra failures are caused by a self.logger assignment in the new WebDriverDigitalCredentialsPart.setup()ProtocolPart.logger is a read-only @property. Two inline suggestions below.

Comment thread tools/wptrunner/wptrunner/executors/executorwebdriver.py Outdated
Comment thread tools/wptrunner/wptrunner/executors/executorwebdriver.py Outdated
Co-authored-by: Marcos Cáceres <marcos@marcosc.com>
@marcoscaceres
Copy link
Copy Markdown
Contributor

marcoscaceres commented May 14, 2026

Looks great... will send any bugs (and fixes!) I find!

@marcoscaceres
Copy link
Copy Markdown
Contributor

The macOS infra failure isn't this PR. The single unexpected result is /infrastructure/testdriver/bidi/emulation/set_touch_override.https.html, failing with webdriver.error.JavascriptErrorException: javascript error (500): A JavaScript exception occured: cannot serialize cyclic structures. — the same error that several sibling BiDi testdriver tests already carry as KNOWN-INTERMITTENT-ERROR in this run.

The test has metadata saying if product != "chrome": ERROR, but wptrunner reports expected OK and flags it as unexpected, so the metadata isn't being honoured (or is incomplete). Either way, nothing in this PR touches that code path.

Filing a separate infra issue. Safe to ignore on your side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

digital-credentials infra testdriver.js wg-s_fedid wptrunner The automated test runner, commonly called through ./wpt run

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants